/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package connection_SQlite;

import java.sql.*;
import java.lang.*;

/**
 *
 * @author Systems
 */
public class test {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) throws ClassNotFoundException {
        // load the sqlite-JDBC driver using the current class loader
        Class.forName("org.sqlite.JDBC");
        Connection connection = null;

        try {
            // create a database connection

            connection = DriverManager.getConnection("jdbc:sqlite:C:\\Users\\Systems\\Desktop\\Conexion.sqlite");
            Statement statement = connection.createStatement();
            statement.setQueryTimeout(30);  // set timeout to 30 sec.

            //ingresando lo datos de la tabla

            /*
             * statement.executeUpdate("drop table if exists Celula");
             * statement.executeUpdate("create table Celula (id_Celula integer,
             * Lado integer, Vertices integer, Cara String)");
             */
            System.out.println("Vamos a ingresar datos en la tabla celula");
            statement.executeUpdate("INSERT INTO Celula VALUES (4, 4, 4,'cuadrado')");
            System.out.println("Hemos ingresado una nueva celula");
            ResultSet rs = statement.executeQuery("select * from Celula");
            while (rs.next()) {
                // read the result set
                System.out.println("id_Celula = " + rs.getString(2));
            }
        } catch (SQLException e) {
            // if the error message is "out of memory", 
            // it probably means no database file is found
            System.err.println(e.getMessage());
        } catch (Exception e) {
            // if the error message is "out of memory", 
            // it probably means no database file is found
            System.err.println(e.getMessage());
        } finally {
            try {
                if (connection != null) {
                    connection.close();
                }
            } catch (SQLException e) {
                // connection close failed.
                System.err.println(e);
            }
        }
    }
}
